<template>
    <basic-container>
        <avue-crud :option="option"
                   :data="data"
                   ref="crud"
                   v-model="form"
                   :table-loading="loading"
                   :permission="permissionList"
                   :page="page"
                   @refresh-change="refreshChange"
                   @search-change="searchChange"
                   @search-reset="searchReset"
                   @current-change="currentChange"
                   @size-change="sizeChange"
				   @selection-change="selectionChange"
                   @on-load="onLoad">
			<template slot-scope="scope" slot="orderSn">
				<el-button size="mini" type="text" style="color: #F39800;" @click="viewDetail(scope.row.orderId, scope.row.userName)">{{scope.row.orderSn}}</el-button>
			</template>	   
            <template slot-scope="scope" slot="menu">
                <el-button v-if="scope.row.replyContent" type="text" size="mini" icon="el-icon-view" @click="evaluateEdit(scope.row,'check')">查看</el-button>
                <el-button v-else type="text" size="mini" icon="el-icon-edit" @click="evaluateEdit(scope.row,'reply')">回复</el-button>
            </template>
			<template slot-scope="scope" slot="menuLeft">
				<el-button type="primary" size="mini" @click="outCheckExcel">导出勾选</el-button>
				<el-button type="primary" size="mini" @click="outExcel">导出商品评价</el-button>
			</template>
        </avue-crud>
        <el-drawer
                :title=dynamicLable
                :visible.sync="evaluateDialogVisible"
                size="50%"
				@close = "cancel()"
        >
			<div style="padding: 20px;">
				<el-form ref="editFormRef" :model="editForm" :rules="editFormRules"   label-width="150px">
					<el-form-item label="商品名称:">
						<el-input v-model="editForm.goodsName" disabled></el-input>
					</el-form-item>
					<el-form-item label="商品规格:">
						<el-input v-model="editForm.skuName" disabled></el-input>
					</el-form-item>
					<el-form-item label="买家名称:">
						<el-input v-model="editForm.userName" disabled></el-input>
					</el-form-item>
					<el-form-item label="服务态度所得分">
						<el-input v-model="editForm.serviceAttitudeScore" disabled></el-input>
					</el-form-item>
					<el-form-item label="物流服务所得分">
						<el-input v-model="editForm.deliveryServiceScore" disabled></el-input>
					</el-form-item>
					<el-form-item label="描述符合度所得分">
						<el-input v-model="editForm.descriptionScore" disabled></el-input>
					</el-form-item>
					<el-form-item label="买家评价时间:">
						<el-input v-model="editForm.addTime" disabled></el-input>
					</el-form-item>
					<el-form-item label="买家评价信息:">
						<el-input v-model="editForm.content" type="textarea" disabled></el-input>
					</el-form-item>
					<el-form-item label="买家评价图片:">
						<div class="demo-image__preview" v-if="img.length>0">
							<el-image v-if="item" v-for="(item,index) in img" :key="index" :preview-src-list="img" :src="item" style="width: 100px; height: 100px;border: 1px solid #E0E2E4;margin-right: 10px;">
							</el-image>
						</div>
						<div class="demo-image__preview" v-else>
							<div slot="error" class="image-slot">
								<div class="no-image">无评价图片</div>
							</div>
						</div>
					</el-form-item>
					<el-form-item label="买家追评信息:">
						<el-input v-model="editForm.appendContent" type="textarea" disabled></el-input>
					</el-form-item>
					<el-form-item label="买家追评图片:">
						<div class="demo-image__preview" v-if="append.length>0">
							<el-image v-if="item"  v-for="(item,index) in append" :key="index" :preview-src-list="append"  :src="item"  style="width: 100px; height: 100px;border: 1px solid #E0E2E4;margin-right: 10px;">
							</el-image>
						</div>
						<div class="demo-image__preview" v-else>
							<el-image>
								<div slot="error" class="image-slot">
									<div class="no-image">无追评图片</div>
								</div>
							</el-image>
						</div>
					</el-form-item>
					<el-form-item label="卖家店铺:">
						<el-input v-model="editForm.storeName" disabled></el-input>
					</el-form-item>
					<el-form-item label="回复评论:" prop="replyContent">
						<el-input type="textarea" v-model="editForm.replyContent" :disabled="!isReply"></el-input>
					</el-form-item>
				</el-form>
				<div style="margin: 50px auto;">
					<div style="width:200px;margin: 0px auto;">
						<el-button size="mini" v-if="isReply" @click="cancel()">取 消</el-button>
						<el-button  size="mini" type="primary"  v-if="isReply" @click="editEvaluateDialog('editFormRef')" :loading="loadAddBtn">确 定</el-button>
					</div>
				</div>
			</div>
        </el-drawer>
		<el-drawer title="订单详情" :with-header="false" :visible.sync="dialogDeatilVisible" size="60%">
			<avue-form :option="optionDetail" v-model="form1">
				<template slot="group1Header">
					<h4 class="avue-group__title">订单详情</h4>
				</template>
				<template slot="group2Header">
					<h4 class="avue-group__title">卖家信息</h4>
				</template>
				<template slot="group3Header">
					<h4 class="avue-group__title">配货单信息</h4>
				</template>
				<template slot="group4Header">
					<h4 class="avue-group__title">优惠信息</h4>
				</template>
				<template slot="group5Header">
					<h4 class="avue-group__title">收货地址</h4>
				</template>
				<template slot="group6Header">
					<h4 class="avue-group__title">门店自提信息</h4>
				</template>
				<template slot="group7Header">
					<h4 class="avue-group__title">操作历史</h4>
				</template>
				<template slot-scope="scope" slot="menuForm">
					<el-button @click="closeDetailDialog">关闭</el-button>
				</template>
		
				<template slot-scope="scope" slot="coupon">
					<div>
						<p>
							运费：
							<span style="padding: 0 0.3rem;">{{ form1.actualShipmentAmount }}</span>
						</p>
						<p v-if="form1.orderType != 2">
							店铺优惠：
							<span style="padding: 0 0.3rem;">{{ form1.couponAmountStore }}</span>
						</p>
						<p v-if="form1.orderType != 2">
							平台优惠：
							<span style="padding: 0 0.3rem;">{{ form1.couponAmountPlatform }}</span>
						</p>
						<!-- <p v-if="form1.fullCutAmount > 0">满减优惠：<span style="padding: 0 0.3rem;">{{form1.fullCutAmount}}</span></p>
						<p v-if="form1.fullDiscountAmount > 0">满折优惠：<span style="padding: 0 0.3rem;">{{form1.fullDiscountAmount}}</span></p> -->
						<p v-if="form1.orderType != 2">
							订单总价：
							<span style="padding: 0 0.3rem;">{{ form1.totalPrice }}</span>
						</p>
						<p v-if="form1.orderType != 2">
							总付款：
							<span style="padding: 0 0.3rem;">{{ form1.lastAmount }}</span>
						</p>
						<p v-if="form1.orderType == 2">
							总付积分：
							<span style="padding: 0 0.3rem;">{{ form1.lastAmount }}</span>
						</p>
						<p v-if="form1.storeReward != null">
							商家奖励团长金额：
							<span style="padding: 0 0.3rem;">{{ form1.storeReward }}</span>
						</p>
						<p v-if="form1.platformReward != null">
							平台奖励团长金额：
							<span style="padding: 0 0.3rem;">{{ form1.platformReward }}</span>
						</p>
					</div>
				</template>
		
				<template slot-scope="scope" slot="goodsDetails">
					<avue-crud :data="form1.goodsDetail" :option="option1">
						<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
							<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
						</template>
						<template slot-scope="{ row }" slot="goodsName">
							<div>
								{{ row.goodsName }}
								<span style="color: red;" v-if="row.acType == 8">[赠品]</span>
							</div>
						</template>
					</avue-crud>
				</template>
		
				<template slot-scope="scope" slot="invoiceType">
					<div>
						<p v-if="form1.invoiceType == 0">个人</p>
						<p v-if="form1.invoiceType == 1">单位</p>
						<p v-if="form1.invoiceType == 2">不开发票</p>
					</div>
				</template>
				<template slot-scope="scope" slot="invoiceTitle">
					<p>{{ form1.invoiceTitle }}</p>
				</template>
				<template slot-scope="scope" slot="invoiceNum">
					<p>{{ form1.invoiceTaxNum }}</p>
				</template>
		
				<template slot-scope="scope" slot="history">
					<div style="padding: 0.2rem;">
						<p v-for="item in form1.historyLog" :key="item.id">
							<span style="padding: 0 0.1rem;" v-if="item.stateInfo">{{ item.stateInfo }}：</span>
							<span style="color: #ff9900;padding: 0 0.2rem;">{{ item.userName }}</span>
							<span style="padding: 0 0.1rem;" v-if="item.stateInfo == '订单取消'">
								于
								<span style="padding: 0 0.1rem;">{{ item.addTime }}</span>
								取消订单
								<p style="padding: 0 0.1rem;">取消原因：{{ item.logInfo }}</p>
							</span>
							<span style="padding: 0 0.1rem;" v-else>
								于
								<span style="padding: 0 0.1rem;">{{ item.addTime }}</span>
								{{ item.logInfo }}
							</span>
						</p>
					</div>
				</template>
		
				<template slot-scope="scope" slot="distributionSn">
					<div>
						<div class="distribution" v-if="form1.orderDistributionList.length == 0">暂无配货单信息</div>
						<div class="distribution" v-for="item in form1.orderDistributionList" :key="item.id">
							<el-form :model="item">
								<el-form-item>
									<span style="padding: 0.1rem 0.5rem">配货单号：{{ item.distributionSn }}</span>
									<span style="padding: 0.1rem 0.5rem">生成时间：{{ item.addTime }}</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 0">配货单状态：未发货</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 1">配货单状态：已发货</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 2">配货单状态：已完成</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 3">配货单状态：已退款</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 4">配货单状态：已收货</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == -1">配货单状态：退款审核</span>
								</el-form-item>
								<el-form-item v-if="item.orderFormGoodsResultList.length > 0">
									<avue-crud ref="crud2" :option="option1" :data="item.orderFormGoodsResultList">
										<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
											<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
										</template>
										<template slot-scope="{ row }" slot="goodsName">
											<div>
												{{ row.goodsName }}
												<span style="color: red;" v-if="row.acType == 8">[赠品]</span>
											</div>
										</template>
									</avue-crud>
								</el-form-item>
								<el-form-item v-else>
									<avue-crud ref="crud2" :option="option1" :data="form1.goodsDetail">
										<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
											<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
										</template>
										<template slot-scope="{ row }" slot="goodsName">
											<div>
												{{ row.goodsName }}
												<span style="color: red;" v-if="row.acType == 8">[赠品]</span>
											</div>
										</template>
									</avue-crud>
								</el-form-item>
								<!--<el-form-item v-if="item.orderFormGoodsResultList.length !=0">-->
								<!--<avue-crud ref="crud2" :option="option1" :data="form1.goodsDetail">-->
								<!--<template slot-scope="{row}" slot="goodsMainPhotoUrl">-->
								<!--<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />-->
								<!--</template>-->
								<!--</avue-crud>-->
								<!--</el-form-item>-->
								<el-form-item v-if="form1.expressType == 1">
									<p>物流公司：{{ item.ecName }}</p>
									<p>物流单号：{{ item.shipCode }}</p>
									<span v-if="item.expressInfoBean != '' && item.expressInfoBean != undefined && item.expressInfoBean != null">
										<el-steps direction="vertical" :active="item.expressInfoBean.data.length">
											<el-step
												v-for="(obj, index) in item.expressInfoBean.data"
												icon="el-icon-success"
												:key="index"
												style="padding: 0.2rem;"
												:description="obj.time + obj.context"
											></el-step>
										</el-steps>
									</span>
								</el-form-item>
							</el-form>
						</div>
					</div>
				</template>
			</avue-form>
		</el-drawer>
    </basic-container>
</template>

<script>
    import {
        getList,
        update,
        add
    } from "@/api/base/transaction/seller/evaluate";
	import {
		getDetail,
	} from '@/api/order/seller/orderForm';
	import { getStoreWillCallId} from '@/api/order/orderForm';
    import { mapGetters } from "vuex";
	import {getToken} from '@/util/store';
    var Dict = JSON.parse(localStorage.getItem('mall-dictionary')).content;
    export default {
        data () {
            return {
            	idList:[],
				form1:{},
				dialogDeatilVisible:false,
				//查看详情
				optionDetail: {
					size: 'mini',
					submitBtn: false,
					emptyBtn: false,
					labelWidth: '100',
					group: [
						{
							prop: 'group1',
							column: [
								{
									label: '订单编号',
									prop: 'orderId',
									type: 'text',
									disabled: true,
								},
								{
									label: '订单状态',
									type: 'select',
									prop: 'orderStatus',
									disabled: true,
									dicData: Dict.orderStatusEnum
								},
								{
									label: '买家名称',
									prop: 'userName',
									disabled: true,
								},
								{
									label: '下单时间',
									prop: 'addTime',
									disabled: true,
								},
								{
									label: '支付时间',
									prop: 'oPayTime',
									disabled: true,
								},
								{
									label: '支付方式',
									prop: 'payWay',
									type: 'select',
									dicData: Dict.payWayEnum,
									disabled: true
								},
								{
									label: '配送方式',
									prop: 'expressType',
									disabled: true,
									type: 'select',
									dicData: Dict.expressTypeEnum,
								},
								{
									label: '业务发生区域',
									labelWidth: 100,
									prop: 'regionalOrganizationStr',
									disabled: true,
								},
								{
									label: '业务发生单元',
									labelWidth: 100,
									prop: 'businessUnitOrganizationStr',
									disabled: true,
								},
								{
									label: '业务发生项目',
									labelWidth: 100,
									prop: 'itemOrganizationStr',
									disabled: true,
								}
							]
						},
						{
							//卖家信息
							prop: 'group2',
							column: [
								{
									label: '店铺名称',
									prop: 'storeName',
									disabled: true,
								},
								{
									label: '店铺账号ID',
									prop: 'tripartiteStoreId',
									disabled: true,
								},
								{
									label: '店铺类型',
									prop: 'storeTypeName',
									disabled: true,
								},
								{
									label: '卖家名称',
									prop: 'storeName',
									disabled: true,
								},
								{
									label: '电话号码',
									prop: 'sellerPhoneNumber',
									disabled: true,
								},
								{
									label: '详细地址',
									prop: 'sellerAddress',
									disabled: true,
								}
							]
						},
						{
							//配货单信息
							prop: 'group3',
							column: [
								{
									prop: 'distributionSn',
									formslot: true,
									span: 24
								}
							]
						},
						{
							//优惠信息
							prop: 'group4',
							column: [
								{
									prop: 'coupon',
									formslot: true
								}
							]
						},
						{
							//收货地址
							prop: 'group5',
							column: [
								{
									label: '收货人',
									prop: 'trueName',
									disabled: true,
								},
								{
									label: '收货地址',
									prop: 'address',
									disabled: true,
								},
								{
									label: '详细地址',
									prop: 'areaInfo',
									disabled: true,
								},
								{
									label: '电话号码',
									prop: 'mobile',
									disabled: true,
								},
								{
									label: '买家留言',
									prop: 'buyerMsg',
									disabled: true,
								},
								// {
								// 	label: '发票类型',
								// 	prop: 'invoiceType',
								// 	formslot: true,
								// 	display: true
								// },
								// {
								// 	label: '发票抬头',
								// 	prop: 'invoiceTitle',
								// 	display: true,
								// 	formslot: true
								// },
								// {
								// 	label: '纳税人识别号',
								// 	prop: 'invoiceNum',
								// 	labelWidth: 120,
								// 	display: true,
								// 	formslot: true
								// }
							]
						},
						{
							//门店自提信息
							prop: 'group6',
							display: false,
							column: [
								{
									label: '配货单号',
									prop: 'distributionSn',
									disabled: true,
								},
								{
									label: '自提时间',
									prop: 'storeWillCallTime',
									disabled: true,
								},
								{
									label: '门店信息',
									prop: 'storeWillInfo',
									disabled: true,
								},
								{
									label: '门店地址',
									prop: 'storeWilladdress',
									disabled: true,
								},
								{
									label: '门店电话',
									prop: 'phone',
									disabled: true,
								},
								{
									label: '操作说明',
									prop: 'distributionDesc',
									disabled: true,
								}
							]
						},
						{
							//操作历史
							prop: 'group7',
							column: [
								{
									prop: 'history',
									formslot: true,
									span: 24
								}
							]
						}
					]
				},
				//宝贝详情
				option1: {
					border: true,
					header: false,
					menu: false,
					size: 'mini',
					align: 'center',
					menuAlign: 'center',
					column: [
						{
							label: '商品名称',
							prop: 'goodsName'
						},
						{
							label: '宝贝图片',
							prop: 'goodsMainPhotoUrl',
							width: 80,
							slot: true
						},
						{
							label: '商品大类',
							prop: 'goodsClassName1',
							width: 80
						},
						{
							label: '商品子类',
							prop: 'goodsClassName2',
							width: 80
						},
						{
							label: '商品小类',
							prop: 'goodsClassName3',
							width: 100
						},
						{
							label: '是否退款退货/仅退款',
							prop: 'orRefund',
							width: 170
						},
						{
							label: '商品类型',
							width: 100,
							prop: 'choiceType',
							dicData: Dict.GOODS_CHOICE_TYPE
						},
						{
							label: '商品规格',
							prop: 'specInfo',
							width: 120
						},
						{
							label: '商品单价',
							width: 70,
							prop: 'price'
						},
						{
							label: '商品数量',
							width: 70,
							prop: 'count'
						},
						{
							label: '商品小计',
							width: 70,
							prop: 'orderFormGoodsTotalPrice'
						},
						{
							label: '平台活动-团长分销拼团价格立减',
							prop: 'platformLeaderDistributionCut',
							width: 120
						},
						{
							label: '平台活动-余额抵扣',
							prop: 'platformBalanceDeduction',
							width: 120
						},
						{
							label: '平台活动-优惠券优惠',
							prop: 'mallCouponAmount',
							width: 120
						},
						{
							label: '平台活动汇总',
							prop: 'platformActivitySummary',
							width: 120
						},
						{
							label: '商家活动-秒杀立减',
							prop: 'storeSpikeCut',
							width: 120
						},
						{
							label: '商家活动-满额立减',
							prop: 'fullCutPrice',
							width: 120
						},
						{
							label: '商家活动-优惠券立减',
							prop: 'storeCouponAmount',
							width: 120
						},
						{
							label: '商家活动-团长分销拼团立减',
							prop: 'storeLeaderDistributionCut',
							width: 120
						},
						{
							label: '商家活动-普通拼团活动立减',
							prop: 'storeCommonGroup',
							width: 120
						},
						{
							label: '商家活动汇总',
							prop: 'storeActivitySummary',
							width: 120
						},
						{
							label: '商家活动-满赠 是否 ',
							prop: 'orGift',
							width: 120
						},
						{
							label: '商品约定结算价',
							width: 100,
							prop: 'purchasePrice'
						},
						{
							label: '商品提佣比例',
							width: 100,
							prop: 'commissionRate'
						},
						{
							label: '公司所得差额',
							prop: 'commissionValue',
							width: 100
						},
						{
							label: '退款金额',
							prop: 'refundPrice',
							width: 70
						}
						// {
						// 	label: "退款状态",
						// 	prop: "user1",
						// 	width:70,
						// },
					]
				},
				photos:[],//预览图片
                evaluateDialogVisible:false,
                form: {},
                evaluateStatus:1,
                query: {},
                data: [],
				img:[], //买家评论图片
				append:[], // 买家追评图片
                editForm:{
					replyContent:''
				},
				editFormRules: {
					replyContent: [
						{required: true, message: '请输入回复内容', trigger: 'blur'},
					],
				},
                loading: true,
                rolesTree: [],
                rolesKeys: [],
                box: false,
				isReply:false,
				loadAddBtn:false,
				dynamicLable:'查看',
                page: {
                    pageSize: 10,
                    currentPage: 1,
                    total: 0
                },
                option: {
                    size: 'mini',
                    // excelBtn: true,
                    tip: true,
                    border: true,
                    index: false,
                    addBtn:false,
                    router:true,
                    "viewBtn": false,
                    "delBtn": false,
                    editBtn:false,
                    columnBtn:false,
                    "refreshBtn": false,
                    selection: true,
                    "align": "center",
                    "searchBtn": false,
                    excelBtn:false,
                    rowKey: 'id',
                    height: 'auto',
                    // calcHeight: 380,
                    dialogType: 'dialog',
                    menuWidth: 100,
                    searchMenuSpan:6,
                    column: [{
							label: "订单号",
							prop: "orderSn",
							slot:true,
							width:160,
							search: true
						},
                        {
                            label: "商品名称",
                            prop: "goodsName",
                            search:true,
                        },
                        {
                            label: "买家名称",
                            prop: "userName",
							width:150,
                            fixed: true,
                        },
                        {
                            label: "商品评分",
                            prop: "avgScore",
                            width:150,
                        },
                        {
                            label: "商品评分排序",
                            prop: "orderByType",
							search:true,
							type:'select',
							searchLabelWidth: 120,
							dicData:[{
								value:0,
								label:'评分升序'
							},{
								value:1,
								label:'评分降序'
							}],
							hide:true,
                        },
                         {
                            label: "卖家店铺",
                            prop: "storeName",
							width:200,
                        },
                        {
                            label: "评价状态",
                            prop: "status",
                            type: 'select',
                            search: false,
                            dicData: Dict.evaluateEnum,
                            width:100,
                        },
                    ]
                },
            };
        },
        computed: {
            ...mapGetters(["permission", 'userInfo']),
            permissionList () {
                return {

                };
            },
        },
		
        methods: {
			viewDetail(id, userName) {
				getDetail(id).then(res => {
					if (res.data.code == 200) {
						let data = res.data.data;
						this.form1.userName = userName;
						this.form1.regionalOrganizationStr = data.regionalOrganizationStr;
						this.form1.businessUnitOrganizationStr = data.businessUnitOrganizationStr;
						this.form1.itemOrganizationStr = data.itemOrganizationStr;
						this.form1.orderId = data.orderForm.orderId;
						this.form1.addTime = data.orderForm.addTime;
						this.form1.payWay = data.orderForm.payWay;
						this.form1.oPayTime = data.orderForm.oPayTime;
						this.form1.storeName = data.orderForm.storeName;
						this.form1.storeTypeName = data.store.storeTypeName;
						this.form1.tripartiteStoreId = data.store.tripartiteStoreId;
						this.form1.orderStatus = data.orderForm.orderStatus;
						this.form1.storeWillInfo = data.orderForm.storeWillCallName;
						this.form1.sellerPhoneNumber = data.orderForm.sellerPhoneNumber;
						this.form1.sellerAddress = data.orderForm.sellerAddress;
						data.orderDistributionList.forEach(item=>{
							if(item.orderFormGoodsResultList!=""){
								item.orderFormGoodsResultList.forEach(good=>{
									good.purchasePrice = good.goodsSkuData.purchasePrice
									good.commissionRate = good.goodsSkuData.commissionRate
									good.commissionValue = good.goodsSkuData.commissionValue
								})
							}
						})
						this.form1.orderDistributionList = data.orderDistributionList;
						this.form1.goodsDetail = data.orderGoodsList;
						this.form1.trueName = data.orderAddress.trueName;
						this.form1.zip = data.orderAddress.zip;
						this.form1.address = data.orderAddress.provinceAreaName + data.orderAddress.cityAreaName + data.orderAddress.countyAreaName;
						this.form1.areaInfo = data.orderAddress.areaInfo;
						this.form1.address = data.orderAddress.address;
						this.form1.mobile = data.orderAddress.mobile;
						this.form1.buyerMsg = data.orderFormInfoResultList[0].buyerMsg;
						// this.form1.invoiceType = data.orderFormInfoResultList[0].invoiceType; //发票类型
						// this.form1.invoiceTitle = data.orderFormInfoResultList[0].invoiceTitle; //发票抬头
						// this.form1.invoiceTaxNum = data.orderFormInfoResultList[0].invoiceTaxNum; //纳税人识别号
						this.form1.expressType = data.orderFormInfoResultList[0].expressType; //运输类型
						this.form1.expressCompanyName = data.orderFormInfoResultList[0].expressCompanyName; //物流公司名
						this.form1.shipCode = data.orderFormInfoResultList[0].shipCode; //快递单号
						this.form1.totalPrice = data.orderForm.totalPrice; //订单总价
						this.form1.lastAmount = data.orderFormAmount[0].lastAmount; //总付款
						this.form1.actualShipmentAmount = data.orderFormAmount[0].actualShipmentAmount; //运费
						this.form1.couponAmountPlatform = data.orderFormAmount[0].couponAmountPlatform; //平台优惠
						this.form1.fullCutAmount = data.orderFormAmount[0].fullCutAmount; //满减优惠fullDiscountAmount
						this.form1.fullDiscountAmount = data.orderFormAmount[0].fullDiscountAmount; //满折优惠
						this.form1.couponAmountStore = data.orderFormAmount[0].couponAmountStore; //店铺优惠
						this.form1.isUseIntegral = data.orderFormAmount[0].isUseIntegral; //是否使用积分抵扣
						this.form1.integralTotalAmount = data.orderFormAmount[0].integralTotalAmount; //积分抵扣金额
						this.form1.historyLog = data.logList; //操作历史
						this.form1.orderType = data.orderForm.orderType; //订单类型
						this.form1.platformReward = data.platformReward;
						this.form1.storeReward = data.storeReward;
						console.log(this.form1.historyLog);
						if(this.form1.expressType==0){//自提
							this.optionDetail.group[4].display=false
							this.optionDetail.group[5].display=true
							getStoreWillCallId(data.orderForm.storeWillCallId).then(res1=>{
								this.form1.phone = res1.data.data.phone
								this.form1.storeWillInfo = res1.data.data.storeName
								this.form1.storeWilladdress = res1.data.data.address
								
							})
						}else{
							this.optionDetail.group[4].display=true
							this.optionDetail.group[5].display=false
						}
						if (data.orderDistributionList.length > 0) {
							this.form1.distributionSn = data.orderDistributionList[0].distributionSn
							this.form1.distributionDesc = data.orderDistributionList[0].distributionDesc || ' '
							this.form1.storeWillCallTime = data.orderDistributionList[0].storeWillCallBeginTime.split(" ",1) +" -- "+ data.orderDistributionList[0].storeWillCallEndTime.split(" ",1) || ' '
						}
						this.dialogDeatilVisible = true;
					} else {
						return;
					}
				});
				setTimeout(() => {
					console.log(this.form1.orderType);
					if (this.form1.orderType == 2) {
						//积分订单
						// this.optionDetail.group[4].column[5].display = false; //发票类型
						// this.optionDetail.group[4].column[6].display = false; //发票抬头
						// this.optionDetail.group[4].column[7].display = false; //纳税人识别号
						// console.log(this.optionDetail.group);
					} else {
						//普通订单
						// this.optionDetail.group[4].column[5].display = true; //发票类型
						// this.optionDetail.group[4].column[6].display = true; //发票抬头
						// this.optionDetail.group[4].column[7].display = true; //纳税人识别号
					}
			
					if (this.form1.invoiceType == 0) {
						//个人发票
						// this.optionDetail.group[4].column[6].display = true;
						// this.optionDetail.group[4].column[7].display = false;
					} else if (this.form1.invoiceType == 2) {
						//不开发票
						// this.optionDetail.group[4].column[6].display = false;
						// this.optionDetail.group[4].column[7].display = false;
					} else if (this.form1.invoiceType == 1) {
						// this.optionDetail.group[4].column[6].display = true;
						// this.optionDetail.group[4].column[7].display = true;
					}
				}, 1000);
				
			},
			closeDetailDialog() {
				this.dialogDeatilVisible = false;
			},
			outExcel(){
				let token = getToken();
				let goodsName = this.query.goodsName === undefined ? "" : this.query.goodsName;
				let orderSn = this.query.orderSn === undefined ? "" : this.query.orderSn;
				let orderByType = this.query.orderByType === undefined ? "" : this.query.orderByType;
				window.location.href = 'evaluate/sellerGoodsComment/outExcel?token=' + token
						+ '&orderSn=' + orderSn
						+ '&orderByType=' + orderByType
						+ '&goodsName=' + goodsName;
			},
			outCheckExcel(){
				if (this.idList.length>0){
				let token = getToken();
				let goodsName = this.query.goodsName === undefined ? "" : this.query.goodsName;
				let orderSn = this.query.orderSn === undefined ? "" : this.query.orderSn;
				let orderByType = this.query.orderByType === undefined ? "" : this.query.orderByType;
				let idList=this.idList;
				window.location.href = 'evaluate/sellerGoodsComment/outExcel?token=' + token
						+ '&orderSn=' + orderSn
						+ '&orderByType=' + orderByType
						+ '&goodsName=' + goodsName
					    + '&idList='+idList;
				}else {
					this.$message({
						type: "error",
						message: "至少选择一项数据!"
					});
				}
			},
            rowSave (row, loading, done) {
                row.position = row.positionIds;
                row.deptName = row.$deptId;
                row.repassword = row.password;
                add(row).then(() => {
                    loading();
                    this.onLoad(this.page);
                    this.$message({
                        type: "success",
                        message: "操作成功!"
                    });
                }, error => {
                    done();

                });
            },
			//点击取消关闭回复对话框清空表单数据
			cancel(){
            	this.evaluateDialogVisible = false;
            	this.$refs.editFormRef.resetFields()
			},
            // 编辑
            evaluateEdit(row,type){
				this.img=[]
				this.append=[]
				if(type == 'check'){
					this.isReply = false;
					this.dynamicLable = '查看';
				}
				else if(type == 'reply'){
					this.isReply = true;
					this.dynamicLable = '回复';
				}
                this.editForm = row;
				let imgList = [];
				let appendImgList = [];
				if(row.imgUrlJson!=''){
					imgList = row.imgUrlJson.split('#')
					imgList.splice(imgList.length-1, 1)
				}
				if(row.appendUrl!=''){
					appendImgList = row.appendUrl.split('#')
					appendImgList.splice(appendImgList.length-1, 1)
				}
				row.imgList = imgList
				row.appendImgList = appendImgList
				this.img=imgList
				this.append=appendImgList
                this.evaluateDialogVisible = true;
             //    getList(this.page.currentPage,this.page.pageSize,{id:id}).then((res) => {
             //    this.editForm = Object.assign({},res.data.data[0])
             //
             // })
            }, 
			openPreview(imgUrls) {
				this.photos=[
					{ thumbUrl: imgUrls, url: imgUrls },
				]
				this.$ImagePreview(this.photos);
			},
            editEvaluateDialog(editFormRef){
				this.$refs[editFormRef].validate((valid) => {
					if(valid){
						this.loadAddBtn = true;
						update(this.editForm).then(res=> {
							if(res.data.code == 200){
								this.$message({
									type:"success",
									message: "回复成功!"
								});
								this.onLoad(this.page);
								this.loadAddBtn = false;
								this.evaluateDialogVisible = false;
							}
							else {
								this.loadAddBtn = false;
								this.$message({
									type:"error",
									message: res.data.message
								});
								return;
							}
						})
					}
					else {
						this.loadAddBtn = false;
						return;
					}
				});
            },
            searchReset () {
                this.query = {};
                this.onLoad(this.page);
            },
			selectionChange(list) {
				let idList = []
				if (list.length > 0) {
					for (let item of list) {
						idList.push(item.id)
					}
					console.log(idList)
					this.idList = idList
				} else {
					this.idList = [];
				}
			},
            searchChange (params,done) {
                this.query = params;
                this.page.currentPage=1;
                this.onLoad(this.page, params,done);
            },
            currentChange (currentPage) {
                this.page.currentPage = currentPage;
                this.onLoad(this.page);
            },
            sizeChange (pageSize) {
                this.page.pageSize = pageSize;
                this.onLoad(this.page);
            },
            refreshChange () {
                this.onLoad(this.page);
            },
            onLoad (page, params = {},done) {
                this.loading = true;
				params.deleteStatus=false
                getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
                	if(done){
						done();
					}
                    this.loading = false;
                    const data = res.data;
                    this.page.total = data.count;
                    this.data = data.data;
                });
            }
        }
    };
</script>

<style scoped>
    .avue-crud__menu {
        display: flex;
        -webkit-box-pack: justify;
        -ms-flex-pack: justify;
        justify-content: space-between;
        width: 100%;
        min-height: 0px;
        height: auto;
        overflow: hidden;
        margin-bottom: 0px;
    }
	.demo-image__preview{
		display: contents;
	}
	.evaluateDetail{
		line-height: 20px;
		padding: 10px 0 0 0;
	}
</style>
